class Solution {
public:
    vector<string> sortPeople(vector<string>& names, vector<int>& heights)
    {
        int n = names.size();
        vector<int> ret(names.size());
        for (int i = 0; i < n; i++)
        {
            ret[i] = i;
        }

        sort(ret.begin(), ret.end(), [&](int x, int y)
            {
                return heights[x] > heights[y];
            });

        vector<string> arr;

        for (int i = 0; i < n; i++)
        {
            arr.push_back(names[ret[i]]);
        }
        return arr;
    }
};